package com.liangzhong.model.footballLottery
{
	import com.liangzhong.model.footballLottery.vo.FbLotteryVo;
	import com.liangzhong.model.footballLottery.vo.GuessDetailVo;
	import com.liangzhong.model.footballLottery.vo.GuessVo;
	import com.liangzhong.model.footballLottery.vo.MyGuessVo;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 *竞猜数据管理 
	 * @author lake
	 * 
	 */	
	public class FootballLotteryDataManager extends EventDispatcher
	{
		/**
		 *单例对象 
		 */		
		private static var _instance :FootballLotteryDataManager;
		/**
		 *竞猜列表 
		 */		
		public var fbLotteryList	:Array = [];
		/**
		 *我的竞猜 
		 */		
		public var myGuessList		:Array = [];
		
		public function FootballLotteryDataManager()
		{
			/*var fbLvo :GuessVo = new GuessVo();
			fbLotteryList.push(fbLvo);
			fbLotteryList.push(fbLvo);
			fbLotteryList.push(fbLvo);
			fbLotteryList.push(fbLvo);
			fbLotteryList.push(fbLvo);
			fbLotteryList.push(fbLvo);
			var fbMvo :MyGuessVo = new MyGuessVo();
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);
			myGuessList.push(fbMvo);*/
		}
		public static function get instance():FootballLotteryDataManager
		{
			if(_instance == null)
			{
				_instance = new FootballLotteryDataManager();
			}
			return _instance;
		}
		/**
		 *测试 
		 */		
		private function test():void
		{
			
		}
		/**
		 *解析竞猜列表 
		 * @param data
		 * 
		 */		
		public function parseGuessList(data:Object):void
		{
			fbLotteryList.splice(0);
			var guessVo :GuessVo;
			for each(var obj :Object in data.guess)
			{
				guessVo = new GuessVo();
				guessVo.parse(obj);
				fbLotteryList.push(guessVo);
			}
			fbLotteryList.sortOn("time",Array.DESCENDING | Array.NUMERIC);
			this.dispatchEvent(new Event(Event.CHANGE + "_list"));
		}
		/**
		 * 解析我的竞猜列表 
		 * @param data
		 * 
		 */		
		public function parseMyGuessList(data:Object):void
		{
			myGuessList.splice(0);
			var guessVo :MyGuessVo;
			for each(var obj :Object in data.guess)
			{
				guessVo = new MyGuessVo();
				guessVo.parse(obj);
				myGuessList.push(guessVo);
			}
			myGuessList.sortOn("time",Array.DESCENDING | Array.NUMERIC);
			this.dispatchEvent(new Event(Event.CHANGE + "_my"));
		}
		/**
		 *通过id获取竞猜信息 
		 * @param id
		 * 
		 */		
		public function getGuessInfoById(id :int):FbLotteryVo
		{
			for each(var fbLvo :FbLotteryVo in fbLotteryList)
			{
				if(fbLvo.gid == id)
				{
					return fbLvo;
				}
			}
			return null;
		}
		/**
		 *根据状态返回对应的列表 
		 * @param sts
		 * @return 
		 * 
		 */		
		public function getGuessListByStatus(sts:int):Array
		{
			var tempArr :Array = [];
			for each(var fbLvo :GuessVo in fbLotteryList)
			{
				if(fbLvo.status_1 == sts)
				{
					tempArr.push(fbLvo);
				}
			}
			return tempArr;
		}
		/**
		 *根据状态返回对应的列表 
		 * @param sts
		 * @return 
		 * 
		 */		
		public function getMyGuessListByStatus(sts:int):Array
		{
			var tempArr :Array = [];
			for each(var fbLvo :MyGuessVo in myGuessList)
			{
				if(fbLvo.sstatus == sts)
				{
					tempArr.push(fbLvo);
				}
			}
			return tempArr;
		}
	}
}